package com.aiuren;


import com.aiuren.vo.UserBean;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@SuppressWarnings({"serial","unused","unchecked","static-access"})
public class LoginAction extends ActionSupport implements ModelDriven{
	
	private UserBean ub = new UserBean();
	
	@Override
	public String execute() throws Exception{
		if(ub.getUsername().equals("scott")&&ub.getPassword().equals("tiger")){
			ActionContext.getContext().getSession().put("username", "Kyo");
			return this.SUCCESS;
		}else{
			return "error";
		}
	}
/*	public void validate(){
		if(this.getUsername()==null||this.getUsername().trim().equals("")){
			this.addFieldError("username", "user.required");
		}
		if(this.getPassword()==null||this.getPassword().trim().equals("")){
			this.addFieldError("password", "password required");
		}
	}*/
	public String register() throws Exception{
		ActionContext.getContext().getSession().put("username", ub.getUsername());
		return this.ERROR;
	}

	public UserBean getModel() {
		return ub;
	}
}
